#ifndef _SPI_H
#define _SPI_H
#include "stdio.h"
#include "at32f435_437.h"
#include "delay.h"

#define SPI2_GPIO_CRM_CLK            CRM_GPIOB_PERIPH_CLOCK


#define SPI2_GPIO                    GPIOB
#define SPI2_CLK_PIN                 GPIO_PINS_13
#define SPI2_MISO_PIN								 GPIO_PINS_14
#define SPI2_MOSI_PIN                GPIO_PINS_15



#define SPI2_CS_PIN                  GPIO_PINS_12
#define SPI2_RST_PIN                 GPIO_PINS_10
#define SPI2_DC_PIN                  GPIO_PINS_11


#define SPI2_CLK_PIN_SOURCE          GPIO_PINS_SOURCE13
#define SPI2_MISO_PIN_SOURCE				 GPIO_PINS_SOURCE14
#define SPI2_MOSI_PIN_SOURCE         GPIO_PINS_SOURCE15
#define SPI2_CLK_PIN_MUX_NUM         GPIO_MUX_5


#define CS_Clr()  gpio_bits_reset(SPI2_GPIO,SPI2_CS_PIN)
#define CS_Set()  gpio_bits_set(SPI2_GPIO,SPI2_CS_PIN)



void SPI2_Init(void);
u8 SPI2_ReadWriteByte(u8 TxData);
extern void write_at7456_addr_data(unsigned char addr, unsigned char dat);
extern unsigned char read_at7456_addr_data(unsigned char addr);
extern void write_at7456_data(unsigned char dat);
extern unsigned char read_at7456_data(void);


unsigned char My_read_at7456_addr_data(unsigned char addr, unsigned char dat);

#endif
